<?php
/**
 * 托福接口基础类
 * by Obelisk
 */
namespace app\libs;

use app\modules\cn\models\User;
use yii;
use yii\web\Controller;

class WechatControl extends Controller
{
    public function init()
    {
        $phone = Yii::$app->request->get('phone');
        if($phone==false){
            $phone = Yii::$app->request->post('phone');
        }
        if($phone!=false){
            $data = json_decode(Method::post("https://login.thinkwithu.com/cn/wechat/get-uid", ['phone' => $phone]), true);
            if ($data['code'] == 0) {
                die(json_encode(['code' => '5', 'message' => '用户未注册!']));
            }
            $uid = $data['uid'];
            $userModel = new User();
            $userModel->saveUserMessage($uid);
            Yii::$app->session->set('uid',$uid);
        }

    }

}

?>